package com.gitee.fanx.retty.spring.springmvc;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.gitee.fanx.retty.web.Request;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * @author fanhang
 */
public class RequestParamResolver extends AbstractParamResolver {

	public RequestParamResolver(RequestParam requestParam, String parameterName, Class<?> clazz, ObjectMapper objectMapper) {
		super(requestParam.value(), requestParam.name(), parameterName, requestParam.defaultValue(), requestParam.required(), clazz, objectMapper);
	}

	@Override
	public String getValue(Request request, String name) {
		return request.queryParamFirst(name);
	}

	@Override
	public String toString() {
		return "RequestParam[" + getName() + ']';
	}

}
